package com.sport.setting.controller;

import com.sport.apis.annotation.SportStatus;
import com.sport.model.common.dtos.ResponseResult;
import com.sport.model.setting.dtos.SportEventsGradeSettingDto;
import com.sport.model.setting.dtos.SportPreInfoSettingDto;
import com.sport.model.setting.dtos.SportPreInfoUpdateDto;
import com.sport.model.user.bos.AccountUserBo;
import com.sport.setting.service.SportPreInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 只负责增删改
 */
@Slf4j
@RestController
@RequestMapping("/SportPreInfo")
public class SportPreInfoController {

    private SportPreInfoService sportPreInfoService;

    public SportPreInfoController(@Autowired SportPreInfoService sportPreInfoService) {
        this.sportPreInfoService = sportPreInfoService;
    }

    @PostMapping("/create")
    @SportStatus(sportTargetStatus = SportStatus.InnerStatus.INITIAL_SPORT_MEETING)
    public ResponseResult createSportMeeting(@RequestBody @Validated SportPreInfoSettingDto sportPreInfoSettingDto) {
        return sportPreInfoService.createSportMeeting(sportPreInfoSettingDto);
    }

    @PostMapping("/update")
    @SportStatus(sportTargetStatus = SportStatus.InnerStatus.ORGANIZE_SPORT_MEETING)
    public ResponseResult updateSportMeeting(@RequestBody SportPreInfoUpdateDto sportPreInfoUpdateDto) {
        return sportPreInfoService.updateSportMeeting(sportPreInfoUpdateDto);
    }

    @GetMapping("/getSportMeetingInfo")
    @SportStatus(sportTargetStatus = SportStatus.InnerStatus.ORGANIZE_SPORT_MEETING)
    public ResponseResult getSportMeetingInfo(){
        return sportPreInfoService.getPreInfo(AccountUserBo.getUser().getSchoolTenementId());

    }

    @GetMapping("/obtainSportGrade")
    @SportStatus(sportTargetStatus = SportStatus.InnerStatus.ORGANIZE_SPORT_MEETING)
    public ResponseResult obtainSportGrade() {
        return sportPreInfoService.obtainSportGrade();
    }

    @PostMapping("/chooseSportGrade")
    @SportStatus(sportTargetStatus = SportStatus.InnerStatus.ORGANIZE_SPORT_MEETING)
    public ResponseResult chooseSportGrade(@RequestBody @Validated SportEventsGradeSettingDto sportEventsGradeSettingDto) {
        return sportPreInfoService.chooseSportGrade(sportEventsGradeSettingDto);
    }
}
